//检查登陆表单
var checkLogin = function() {
	
	var nickname = trim(document.getElementById("TxtUserName").value);
	var password = trim(document.getElementById("TxtPassword").value);
	var ifStudentRC = document.getElementById("studentRadio").checked;	//保存，学生是否被选中

	if (nickname == "") {
		document.getElementById("loginWarn").innerHTML = "<img src=\"images/error.png\"/>用户名不能为空！";		
		return false;
	} else if (ifStudentRC == true) {
		var isNum = isStudentNum(nickname);
		if (isNum == false) {
			document.getElementById("loginWarn").innerHTML = "<img src=\"images/error.png\"/>请输入你的学号！";
			return false;
		} else {
			if (nickname.length != 9) {
				document.getElementById("loginWarn").innerHTML = "<img src=\"images/error.png\"/>你输入的学号位数不正确！";
			    return false;
			} else {
				if (password == "") {
					document.getElementById("loginWarn").innerHTML = "<img src=\"images/error.png\"/>密码不能为空！";
					return false;
				} else {
					document.getElementById("loginWarn").innerHTML = "";
					return true;
				}	
			}
		}
	} else if (password == "") {
		document.getElementById("loginWarn").innerHTML = "<img src=\"images/error.png\"/>密码不能为空！";
		return false;
	} else {
		document.getElementById("loginWarn").innerHTML = "";
		return true;
	}
}

//取出两端空格
var trim = function(str) {
	str = str.replace(/^\s+/,"");
	str = str.replace(/\s+$/,"");
	return str;
}

//判断学生输入的是否为学号
var isStudentNum = function(testNum) {
	 var regu = /^[0-9]+.?[0-9]*$/;   //判断字符串是否为数字     //判断正整数 /^[1-9]+[0-9]*]*$/  
	 var re = new RegExp(regu);
	 var isNum = re.test(testNum);
	 return isNum;	
}

